package com.qc31.monitorlib.ui.adapter

import android.content.Context
import android.widget.ImageView
import android.widget.RelativeLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.qc31.baselib.utils.loadStringDImgError
import com.qc31.comlib.entity.PhotoInfo
import com.qc31.monitorlib.R

/** @Author Jasper @Time 2020/10/21 @Desc 照片历史 */
class PhotosHistoryAdapter(private val mContext: Context) :
    BaseQuickAdapter<PhotoInfo, BaseViewHolder>(R.layout.item_history_photo) {
    private val unit = mContext.getString(R.string.unit_speed)
    var index = -1
    override fun convert(holder: BaseViewHolder, item: PhotoInfo) {
        item.run {
            holder.getView<ImageView>(R.id.iv_photo_pic).loadStringDImgError(mContext, fullLink)
            holder.setText(
                R.id.tv_photo_state,
                "$time  $speed $unit"
            )
                .setText(R.id.tv_photo_address, addr)
            holder.getView<RelativeLayout>(R.id.rl_photo_bg).isSelected =
                index == holder.layoutPosition
        }
    }
}